Imports System.Data.Common
Partial Class Presentation_ClientStatus
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim Sql As String
        Dim CountSql As String
        Dim Params(1) As GenParameter
        Page.Title = "View a Client's Status"

        Sql = "SELECT ClientMaster.ClientName, ProjectMaster.ProjectName, DATE_FORMAT(WorkflowMaster.MeetingDate, '%d/%m/%y') AS 'Meeting Date', ActionMaster.ActionDescription, WorkflowMaster.Details, WorkflowMaster.NextAction, DATE_FORMAT(WorkflowMaster.DateofNextAction,'%d/%m/%y') AS 'Date of Next Action'" & _
            " FROM ActionMaster INNER JOIN (ProjectMaster INNER JOIN ((ClientMaster INNER JOIN CompanyAssignments ON ClientMaster.ClientID = CompanyAssignments.ClientID) INNER JOIN WorkflowMaster ON ClientMaster.ClientID = WorkflowMaster.ClientID)" & _
            " ON ProjectMaster.ProjectID = WorkflowMaster.ProjectID) ON ActionMaster.ActionID = WorkflowMaster.ActionID" & _
            " WHERE ClientMaster.ClientName LIKE CONCAT('%',?ClientPart,'%') AND CompanyAssignments.ExecutiveID = ?ExecutiveID" & _
            " ORDER BY ClientMaster.ClientName"

        Params(0) = New GenParameter("?ClientPart", txtClientPart.Text, Data.DbType.String)
        Params(1) = New GenParameter("?ExecutiveID", Request.Cookies("Profile").Item("ExecutiveID"), Data.DbType.UInt32)

        CountSql = "SELECT COUNT(*)" & _
                    " FROM ActionMaster INNER JOIN (ProjectMaster INNER JOIN ((ClientMaster INNER JOIN CompanyAssignments ON ClientMaster.ClientID = CompanyAssignments.ClientID) INNER JOIN WorkflowMaster ON ClientMaster.ClientID = WorkflowMaster.ClientID)" & _
                    " ON ProjectMaster.ProjectID = WorkflowMaster.ProjectID) ON ActionMaster.ActionID = WorkflowMaster.ActionID" & _
                    " WHERE ClientMaster.ClientName LIKE CONCAT('%',?ClientPart,'%') AND CompanyAssignments.ExecutiveID = ?ExecutiveID"

        ClientStatus.Sql = Sql
        ClientStatus.CountSql = CountSql
        ClientStatus.Params = Params
        ClientStatus.ShowButton = True



    End Sub
End Class
